package util;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;

public class MathUtil {
	/**
	 * produce n random numbers which < range
	 * @param size : n
	 * @param range
	 * @return
	 */
	public static HashSet<Integer> randomNumProducer(int size, int range){
		HashSet<Integer> hs = new HashSet<Integer>();	
		
		while(true){
			Random rdm = new Random(System.currentTimeMillis());
			int value = Math.abs(rdm.nextInt()) % range;
			hs.add(value);
			if(hs.size() == size)
				break;
		}
		
		return hs;
	}
	
	public static double calculateLength(ArrayList<Double> weight){
		double length = 0;
		for(double value : weight){
			length += Math.pow(value, 2);
		}
		length = Math.sqrt(length);
		return length;
	}
}
